package tests;

import static org.junit.Assert.*;
import entities.Inventory;
import gstd.Player;

import org.junit.Test;

public class TestFleet {

	// Checks if the method gets the correct rent for one fleet
	@Test
	public void testGetRent() {
		fields.Fleet f = new fields.Fleet("Fleet", 300);
		fields.Fleet f2 = new fields.Fleet("Fleet", 300);
		Player p = new Player("Mr. Cat", new Inventory(300));

		// First test
		((Inventory) p.getInventory()).addField(f);
		f.setOwner(p);
		assertEquals(800, f.getRent() + p.getInventory().getBalance());

		// Second test
		((Inventory) p.getInventory()).addField(f2);
		f2.setOwner(p);
		assertEquals(1300, f.getRent() + p.getInventory().getBalance());
	}

	// Checks if the method transfers the correct value from the player landing
	// to the owner.
	@Test
	public void testLandOnField() {
		fields.Fleet f = new fields.Fleet("Fleet", 200);

		Player p = new Player("Mr. Cat", new Inventory(1000));
		Player pOwner = new Player("Mr. Dog", new Inventory(1000));

		f.setBuyFieldDecision(true);
		f.landOnField(pOwner);

		assertEquals(f.getOwner().getName(), pOwner.getName());
		assertEquals(800, pOwner.getInventory().getBalance());
				
		// First test
		f.landOnField(p);
		
		assertEquals(1300, pOwner.getInventory().getBalance());
		assertEquals(500, p.getInventory().getBalance());
	}

}
